package lightcar;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;

public class LightSource
{
    private lightcar.Point loc;
    private double intensity;
    static private boolean light=false;
    
    LightSource(int x, int y)
    {
        intensity = 100;
        loc = new lightcar.Point(x,y);
    }
    LightSource(Point newPoint)
    {
        intensity=100;
        int x=(int) newPoint.getX();
        int y=(int) newPoint.getY();
        loc = new lightcar.Point(x,y);
        
        
    }
    public lightcar.Point getLocation()
    {
        return loc;
    }
    public double get_intensity(lightcar.Point p)
    {
        //Gets the intensity caused by this light at point loc
        double dist = World.dist(loc, p);
        if(dist <= 0)
        {
            return intensity;
        }
        else
        {
            return intensity / dist;
        }
    }
    public void draw(Graphics g)
    {
        g.setColor(Color.yellow);
        g.fillOval((int)loc.x,(int)loc.y,10,10);
    }
        
    public static void toggleLight()
    {
        light=!light;
        System.out.println("light is now:" + light);
    }
    public static boolean getLight()
    {
        return light;
    }
}
